﻿using System.Data.Entity;
using System.Linq;

namespace CS795.TravelAgency.Domain.Entities.Initializers
{
    public class SeededDBInitializer : CreateDatabaseIfNotExists<TravelAgencyContext>
    {
        protected override void Seed(TravelAgencyContext context)
        {
            // add roles
            Role adminRole = new Role { Id = 1, Name = "Administrators" };
            Role agentRole = new Role { Id = 2, Name = "Agents" };
            Role customerRole = new Role { Id = 3, Name = "Customers" };
            context.Roles.Add(adminRole);
            context.Roles.Add(agentRole);
            context.Roles.Add(customerRole);

            // add users
            context.Users.Add(new User { Id = 1, Name = "Administrator", Salt = "123456", Password = "Yt6KXC5+LzDXeuVZmMtkB8ENGhw=", Email = "admin@abc.com", Roles = (new[] { adminRole }).ToList() });
            context.Users.Add(new User { Id = 2, Name = "Agent", Salt = "123456", Password = "Yt6KXC5+LzDXeuVZmMtkB8ENGhw=", Email = "agent@abc.com", Roles = (new[] { agentRole }).ToList() });
            context.Users.Add(new User { Id = 3, Name = "Customer", Salt = "123456", Password = "Yt6KXC5+LzDXeuVZmMtkB8ENGhw=", Email = "customer@abc.com", Roles = (new[] { customerRole }).ToList() });

            // add vendors
            context.Vendors.Add(new Vendor { Id = 1, Name = "Avis", Type = VendorType.CarRental, ServiceURL = "https://CS795/Services/Avis/CarRental.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 2, Name = "Comfort Inn", Type = VendorType.Hotel, ServiceURL = "https://CS795/Services/ComfortInn/Hotel.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 3, Name = "Days Inn", Type = VendorType.Hotel, ServiceURL = "https://CS795/Services/DaysInn/Hotel.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 4, Name = "Delta", Type = VendorType.Flight, ServiceURL = "https://CS795/Services/Delta/Flight.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 5, Name = "Enterprise", Type = VendorType.CarRental, ServiceURL = "https://CS795/Services/Enterprise/CarRental.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 6, Name = "Hertz", Type = VendorType.CarRental, ServiceURL = "https://CS795/Services/Hertz/CarRental.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 7, Name = "Holiday Inn", Type = VendorType.Hotel, ServiceURL = "https://CS795/Services/HolidayInn/Hotel.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 8, Name = "Northwest", Type = VendorType.Flight, ServiceURL = "https://CS795/Services/Northwest/Flight.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 9, Name = "Sheraton", Type = VendorType.Hotel, ServiceURL = "https://CS795/Services/Sheraton/Hotel.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 10, Name = "United", Type = VendorType.Flight, ServiceURL = "https://CS795/Services/United/Flight.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
            context.Vendors.Add(new Vendor { Id = 11, Name = "US Air", Type = VendorType.Flight, ServiceURL = "https://CS795/Services/USAir/Flight.svc", Username = "EAAAAPqKrFQRBWiiBGxK/42aJPug6zHIBK9HwHlefSGlHYGL", Password = "EAAAABdb+3dfrcaFVWiz0gW49gJ5PwFosleT1n+5DXBrPM/s" });
        }
    }
}
